package com.lsp.rabbitmqcousumer.direct;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.time.LocalDateTime;
import java.util.Map;

/**
 * 死信队列消费者
 * 三种情况会变成死信，会自动投放到改队列
 * x-max-length
 * basicReject basicNack(false)
 * ttl过期
 */
@Component
@RabbitListener(
        bindings = @QueueBinding(
                value = @Queue(
                        value = "shixin_queue"
                ),
                exchange = @Exchange(
                        value = "shixin_exchange"),
                key =  "shixin_key")
)
public class NackOrDeadLetterReceiver2 {
    @RabbitHandler
    public void receiverAck(Map msg, Message message, Channel channel)  throws Exception{
        System.out.println("----------shixin_queue收到消息：" + msg);

    }
}
